# -*- coding: utf-8 -*-
from odoo import models, fields, api
from odoo.exceptions import ValidationError
import datetime

class StudentCourseReport(models.AbstractModel):
    _name = 'report.gym_service_checkin.student_course_report'

    @api.multi
    def render_html(self, docids, data=None):
        docs = self.env['service.class'].browse(docids)
        res_doc = []
        for line in docs:
            order_doc = []
            for row in line.class_checkin_list:
                order_temp = {
                    'checkin_parent_date':row.checkin_parent_date,
                    'checkin_couch':row.checkin_couch,
                    'checkin_amount':row.checkin_amount,
                    'notes':row.notes
                }
                order_doc.append(order_temp)
            temp = {
                'create_date':line.create_date,
                'order_line':order_doc
            }
            res_doc.append(temp)

        docargs = {
            'doc_ids': docids,
            'doc_model': 'service.class',
            'docs': res_doc,
        }
        return self.env['report'].render('gym_service_checkin.student_course_template', values=docargs)